package org.example.management.config;

import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class RabbitConfig {
    @Autowired
    CachingConnectionFactory connectionFactory;
    //rabbitmq模板
    @Bean(value = "rabbitTemplate")
    public RabbitTemplate rabbitTemplate(){
        return new RabbitTemplate(connectionFactory);
    }

    @Bean
    public DirectExchange topicExchange(){
        return new DirectExchange("direct");
    }

    @Bean("promo_info")
    public Queue movieOrderQueue(){
        return new Queue("promo_info");
    }
    @Bean
    public Binding binding(@Qualifier("promo_info") Queue queue, DirectExchange topic){
        return BindingBuilder.bind(queue).to(topic).with("promo_info");
    }


}
